#£¡/bin/sh
resource_name=diana.jar
tpid=`ps -ef|grep $resource_name|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
	echo "1 - ${tpid}"
	echo '1 - stop service...'
	kill -15 $tpid
fi

sleep 5
tpid=`ps -ef|grep $resource_name|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
	echo "2 - ${tpid}"
	echo "2 - forced stop service..."
	kill -9 $tpid
else
	echo '2 - stop service success'
fi

tpid=`ps -ef|grep $resource_name|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
	echo "3 - ${tpid}"
	echo "3 - service is running..."
else
	echo "3 - service is not running"
fi

rm -f tpid
#nohup java -Xms1024m -Xmx1024m -jar ./$resource_name --spring.profile.active=test >/dev/null 2>error.log &
nohup java -Xms512m -Xmx512m -jar ./$resource_name --spring.profiles.active=test >/dev/null 2>error.log &
echo $! > tpid
echo 4 - service start success
